package org.mathcloud.math.core.scilab.operator.algebra;

import org.mathcloud.math.core.common.operator.algebra.Conjugate;
import org.mathcloud.math.core.common.quantity.ComplexNumber;
import org.mathcloud.math.core.common.quantity.RealNumber;
import org.mathcloud.math.core.scilab.operator.ScilabUnaryOperator;
import org.mathcloud.math.core.scilab.quantity.ScilabComplexNumber;
import org.mathcloud.math.core.scilab.quantity.ScilabRealNumber;

public class ScilabConjugate extends ScilabUnaryOperator implements Conjugate
{
	public ScilabConjugate()
	{
		super();
		signature.setMMLContentTag("conjugate");
	}
	
	@Override
	public void calculate()
	{
		if (operand.getSignature().isRealNumberSignature())
			res = new ScilabRealNumber(((RealNumber)operand).getValue());
		else if (operand.getSignature().isComplexNumberSignature())
			res = new ScilabComplexNumber(((ComplexNumber)operand).getRealPart(),-((ComplexNumber)operand).getRealPart());
	}
}
